import * as THREE from "three";

//边框宽度（边框为长方体--面为正方体，所以需要宽度）
var BorderWidth;
//边框几何体的坐标、
var positionX;
var positionY;
var positionZ;
//水平线长度
var length;
//垂直线长度
var width;


export const StoreArea=(option)=>{
//  创建库边的材质对象
  let LineMat = new THREE.MeshLambertMaterial({
    color:0xDFCE19
  });
  BorderWidth=8;
  positionX=option.position.x||0;
  positionY=2.5;
  positionZ=option.position.z||0;

  console.log('positionX',positionX)
  console.log('positionY',positionY)
  console.log('positionZ',positionZ)
  length=option.length||1;
  width=option.width||1;

//  创建水平线的平面几何体
  let LevelGeometry = new THREE.PlaneGeometry(BorderWidth,length);
//  创建垂直线的平面几何体
  let verticalGeometry = new THREE.PlaneGeometry(BorderWidth,width+BorderWidth*2);

//  创建水平线网格模型
  //上线
  let topLine = new THREE.Mesh(LevelGeometry,LineMat);
  topLine.position.set(positionX,positionY,positionZ-width/2-BorderWidth/2);
//  将线旋转为需要的样子(旋转---永远只是按照起始位置的xyz轴来进行旋转)
  topLine.rotation.x= -Math.PI/2.0;
  topLine.rotation.z= -Math.PI / 2.0;
  //下线
  let downLine = topLine.clone();
  downLine.position.z=downLine.position.z+width+BorderWidth;
  //左边线
  let leftLine = new THREE.Mesh(verticalGeometry,LineMat);
  leftLine.position.set(positionX-length/2-BorderWidth/2,positionY,positionZ);
  leftLine.rotation.x=-Math.PI/2.0;
  //右边线
  let rightLine = leftLine.clone();
  rightLine.position.x=rightLine.position.x+length+BorderWidth;

  let group = new THREE.Group();
  group.add(topLine);
  group.add(downLine);
  group.add(leftLine);
  group.add(rightLine);

  // new THREE.FontLoader().load("fonts/helvetiker_regular.typeface.json",function (font) {
  //   ////加入立体文字
  //   var text= new THREE.TextGeometry(option.Title.Text,{
  //     // 设定文字字体
  //     font:font,
  //     //尺寸
  //     size:option.Title.FontSize,
  //     //厚度
  //     height:0.1
  //   });
  //   text.computeBoundingBox();
  //   //3D文字材质
  //   var m = new THREE.MeshStandardMaterial({color:"#" + option.Title.TextColor});
  //   var mesh = new THREE.Mesh(text,m);
  //
  //   mesh.position.y =positionY;
  //   mesh.position.z = option.Title.Position.Z+positionZ;
  //   mesh.position.x = option.Title.Position.X+positionX;
  //   mesh.rotation.x = -Math.PI / 2.0;
  //   mesh.name=option.objName;
  //   group.add(mesh)
  // })
  return group;

}
